<template>
	<view>
		<view class="my" @click="scan">
			asd
		</view>
		<view class="">
			<button @click="to">选择图片</button>
			<image mode="aspectFit" :src="img"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tempimg: '',
				img: '',
			}
		},
		onShow() {
			let that = this;
			//接收裁剪好的图片参数‘updateimg’
			uni.$on('updateimg', function(data) {
				
				that.img = data
				console.log(data);
			})
		},
		methods: {
			to() {
				uni.chooseImage({
					//选择图片进入裁剪页进行修改，将图片临时地址传给参数‘img’
					success: (res) => {
						this.tempimg = res.tempFilePaths[0]
						uni.navigateTo({
							url: '/uni_modules/hy-imgeditor/pages/edit/edit?img=' + this.tempimg
						})
					}
				})

			},
			scan() {
				uni.scanCode({
					success: function(res) {
						console.log('扫码成功', res);
					},
					fail: function(err) {
						console.error('扫码失败', err);
					}
				});
			}
		}
	}
</script>

<style>

</style>